﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using WinApp.Model.EF_Model;

namespace WinApp.Model
{
    public class SqlLiteDbContext : DbContext
    {

        public DbSet<User> Users { get; set; }
        public DbSet<ExamContentData> ExamContentDatas { get; set; }
        public DbSet<Course> Courses { get; set; }

        public DbSet<CourseDetail> CourseDetails { get; set; }

        public DbSet<Exam> Exams { get; set; }


        public string dbPath = Directory.GetCurrentDirectory() + "/XPTDatabase.db";

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //注入Sqlite链接字符串
            if (!optionsBuilder.IsConfigured)
            {
                string path_DB = Environment.CurrentDirectory + "/XPTDatabase.db";
                optionsBuilder.UseSqlite($"Data Source={path_DB}");
            }
        }
    }
}
